﻿Imports Microsoft.Win32

Public Class ThisAddIn
    Public Shared dsWebServices As System.Data.DataSet = Nothing
    Sub LoadWebServices()
        Dim filename As String = ""
        Dim fsReadXML As System.IO.FileStream = Nothing


        Dim row1() As String = {"http://www.earthtools.org/timezone/{0}/{1}", "//timezone/offset"}
        Dim row2() As String = {"http://ws.geonames.org/timezone?lat={0}&lng={1}", "//geonames/timezone/gmtOffset"}
        Dim keyValue() As String
        Dim rootValue As String = "HKEY_CURRENT_USER\Software\Outlook2007DIT\TZWebServices"
        Dim rowId As Integer = 1
        Dim finished As Boolean = False
        Dim exists As Boolean = False

        dsWebServices = New System.Data.DataSet
        dsWebServices.Tables.Add("TZWebService")
        With dsWebServices.Tables("TZWebService")
            .Columns.Add("WebServiceFormatString")
            .Columns.Add("WebServiceResponsePath")
        End With

        Do Until finished = True

            Try
                keyValue = My.Computer.Registry.GetValue(rootValue, rowId, "")
                dsWebServices.Tables("TZWebService").Rows.Add(keyValue)
                exists = True
            Catch ex As Exception
                finished = True
            End Try
            rowId = rowId + 1
        Loop
        If exists = False Then
            My.Computer.Registry.SetValue(rootValue, "1", row1)
            My.Computer.Registry.SetValue(rootValue, "2", row2)
            With dsWebServices.Tables("TZWebService")
                .Rows.Add(row1)
                .Rows.Add(row2)
            End With
        End If
    End Sub
    Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
        LoadWebServices()
    End Sub

    Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown

    End Sub

End Class
